package com.ruoyi.web.controller.nycbfx;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.nycbfx.domain.TbNycbfxNycbhs;
import com.ruoyi.nycbfx.service.ITbNycbfxNycbhsService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 能源成本核算Controller
 * 
 * @author cc
 * @date 2023-11-13
 */
@RestController
@RequestMapping("/nycbfx/nycbhs")
public class TbNycbfxNycbhsController extends BaseController
{
    @Autowired
    private ITbNycbfxNycbhsService tbNycbfxNycbhsService;

    /**
     * 查询能源成本核算列表
     */
    @PreAuthorize("@ss.hasPermi('nycbfx:nycbhs:list')")
    @GetMapping("/list")
    public TableDataInfo list(TbNycbfxNycbhs tbNycbfxNycbhs)
    {
        startPage();
        List<TbNycbfxNycbhs> list = tbNycbfxNycbhsService.selectTbNycbfxNycbhsList(tbNycbfxNycbhs);
        return getDataTable(list);
    }

    /**
     * 导出能源成本核算列表
     */
    @PreAuthorize("@ss.hasPermi('nycbfx:nycbhs:export')")
    @Log(title = "能源成本核算", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, TbNycbfxNycbhs tbNycbfxNycbhs)
    {
        List<TbNycbfxNycbhs> list = tbNycbfxNycbhsService.selectTbNycbfxNycbhsList(tbNycbfxNycbhs);
        ExcelUtil<TbNycbfxNycbhs> util = new ExcelUtil<TbNycbfxNycbhs>(TbNycbfxNycbhs.class);
        util.exportExcel(response, list, "能源成本核算数据");
    }

    /**
     * 获取能源成本核算详细信息
     */
    @PreAuthorize("@ss.hasPermi('nycbfx:nycbhs:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(tbNycbfxNycbhsService.selectTbNycbfxNycbhsById(id));
    }

    /**
     * 新增能源成本核算
     */
    @PreAuthorize("@ss.hasPermi('nycbfx:nycbhs:add')")
    @Log(title = "能源成本核算", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody TbNycbfxNycbhs tbNycbfxNycbhs)
    {
        return toAjax(tbNycbfxNycbhsService.insertTbNycbfxNycbhs(tbNycbfxNycbhs));
    }

    /**
     * 修改能源成本核算
     */
    @PreAuthorize("@ss.hasPermi('nycbfx:nycbhs:edit')")
    @Log(title = "能源成本核算", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody TbNycbfxNycbhs tbNycbfxNycbhs)
    {
        return toAjax(tbNycbfxNycbhsService.updateTbNycbfxNycbhs(tbNycbfxNycbhs));
    }

    /**
     * 删除能源成本核算
     */
    @PreAuthorize("@ss.hasPermi('nycbfx:nycbhs:remove')")
    @Log(title = "能源成本核算", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(tbNycbfxNycbhsService.deleteTbNycbfxNycbhsByIds(ids));
    }
}
